﻿using EGN;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;

namespace EGNTEsts
{
    
    
    /// <summary>
    ///This is a test class for EGNMethodsTest and is intended
    ///to contain all EGNMethodsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class EGNMethodsTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetEGN
        ///</summary>
        [TestMethod()]
        public void GetEGNTest()
        {
            string fileName = @"C:\Users\Academy\Documents\Visual Studio 2010\Projects\.Net Essentiels\Panayot Popov\IntemediateExam1\FrameworkBasicConcepts\EGN\bin\Debug\person.txt";
            string text = @"jsaklfja 6092816084 dasd
                          das ,9876543210  d1234567890";
            StreamWriter write = new StreamWriter(fileName);
            using (write)
            {
                write.WriteLine(text);
            }
            List<string> expected = new List<string>();
            expected.Add("6092816084");
            expected.Add("9876543210");
            List<string> actual;
            actual = EGNMethods.GetEGN(fileName);
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i],actual[i]);
            }
        }

        /// <summary>
        ///A test for PrintEGN
        ///</summary>
        //[TestMethod()]
        //public void PrintEGNTest()
        //{
        //    List<string> toPrint = null; // TODO: Initialize to an appropriate value
        //    EGNMethods.PrintEGN(toPrint);
        //    Assert.Inconclusive("A method that does not return a value cannot be verified.");
        //}

        /// <summary>
        ///A test for ReverseEGN
        ///</summary>
        [TestMethod()]
        public void ReverseEGNTest()
        {
            string fileName = @"C:\Users\Academy\Documents\Visual Studio 2010\Projects\.Net Essentiels\Panayot Popov\IntemediateExam1\FrameworkBasicConcepts\EGN\bin\Debug\person.txt";
            string text = @"jsaklfja 6092816084 dasd das ,9876543210  d1234567890";
            StreamWriter write = new StreamWriter(fileName);
            using (write)
            {
                write.WriteLine(text);
            }
            string expected = "jsaklfja 4806182906 dasd das ,0123456789  d1234567890\r\n";
            EGNMethods.ReverseEgn(fileName);
            StreamReader read = new StreamReader(fileName);
            string actual;
            using (read) 
            {
                 actual= read.ReadToEnd();
            }
            Assert.AreEqual(expected, actual);
        }

       
    }
}
